package edu.sias.controller;

import edu.sias.pojo.S_User;
import edu.sias.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/user/register")
public class UserRegisterServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //获取数据
        String username = request.getParameter("username");
        String psw = request.getParameter("psw");
        String email = request.getParameter("email");
        String phone = request.getParameter("phone");
        String gender = request.getParameter("gender");
        String address = request.getParameter("address");
        //封装到s_user对象中
        S_User s_user = new S_User(username, psw, email, phone, gender, address);
        System.out.println("s_user = " + s_user);
        //调用service中的注册信息操作
        UserService userService = new UserService();
        userService.userRegister(s_user);
        //注册后  默认重新返回登录
//        response.sendRedirect("/login.jsp");
    }


}
